package com.example.caselsconverter;

import com.example.caselscomberter.R;
import android.os.Bundle;
import android.app.Activity;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
		private static final float DOLLAR_VALOR = 0.73f;
		private TextView textViewResult;
		private TextView textView;
		private EditText editText;
		private double result=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        textViewResult=(TextView) findViewById(R.id.textView2);
        textViewResult.setText("Hey User! Les't Work! ^o^");
        editText=(EditText) findViewById(R.id.number);
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    /**
     * called button is pressed
     * @param v
     */
    public void convert(View v) {	
    	Log.d("CASEL","button pressed");
        textViewResult=(TextView) findViewById(R.id.Result);
        	try {
        		result=Double.parseDouble(editText.getText().toString());
                result=result * DOLLAR_VALOR;
                textViewResult.setText(String.valueOf(result) + "$");
			} catch (Exception e) {
				textViewResult.setText("Error");
				// TODO: handle exception
			}
  
        
    }
    
}
